﻿
@{
    ViewData["Title"] = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section Scripts
    {
    <script>
        var editObj = null, ptable = null, treeGrid = null, tableId = 'treeTable', layer = null;
        layui.config({
            base: '/design/extend/'
        }).extend({
            treeGrid: 'treeGrid'
        }).use(['jquery', 'treeGrid', 'layer'], function () {
            var $ = layui.jquery;
            treeGrid = layui.treeGrid;//很重要
            layer = layui.layer;
            ptable = treeGrid.render({
                id: tableId
                , elem: '#' + tableId
                , url: '/Area/GetList'
               // , where: { "PunCode": $("#PunCode").val() }
                , cellMinWidth: 100
                , idField: 'yunCode'//必須字段
                , treeId: 'yunCode'//树形id字段名称
                , treeUpId: 'punCode'//树形父id字段名称
                , treeShowName: 'areaName'//以树形式显示的字段
                , heightRemove: [".dHead", 10]//不计算的高度,表格设定的是固定高度，此项不生效
                , height: '100%'
                , isFilter: false
                , iconOpen: false//是否显示图标【默认显示】
                , isOpenDefault: false//节点默认是展开还是折叠【默认展开】
                , loading: true
                , method: 'post'
                , isPage: false
                , cols: [[
                    { type: 'numbers' }
                    , { field: 'areaName', title: '地区', sort: true }
                    , { field: 'punCode', title: '上级编码', edit: 'text', sort: true }
                    //, {
                    //    width: 100, title: '操作', align: 'center'/*toolbar: '#barDemo'*/
                    //    , templet: function (d) {
                    //        var html = '';
                    //        var addBtn = '<a class="layui-btn layui-btn-primary layui-btn-xs"  href="/SpeciesTypes/Create?Id=' + d.id + '&ParentIds=' + d.pId + '" >添加</a>';
                    //        var editBtn = '<a class="layui-btn layui-btn-primary layui-btn-xs" href="/SpeciesTypes/Edit/' + d.id + '"  >编辑</a>';
                    //        return addBtn + editBtn;
                    //    }
                    //}
                ]]
                , parseData: function (res) {//数据加载后回调
                    return res;
                }
            });


            var $b = layui.$;
            active = {
                reload: function (page) {
                    //执行重载
                    treeGrid.reload('treeTable', {
                        page: {
                            curr: page || 1 //重新从第 1 页开始
                        },
                        where: { PunCode: $("#PunCode").val(), level: $("#level").val(), AreaName: $("#AreaName").val() }

                    });
                }
            };
            $b('#search').on('click', function () {
                var type = $b(this).data('type');
                active[type] ? active[type].call(this) : '';
            });

        });


    </script>
}

<blockquote class="layui-elem-quote layui-text layui-form">
    <div class="layui-inline">
        <label class="layui-form-label">上级编码：</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="PunCode" name="PunCode" style="width:240px" placeholder="">
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">等级：</label>
        <div class="layui-input-inline">
            <select id="level" class="layui-input"name="level" style="width:240px" placeholder="">
                <option value="">请选择</option>
                <option value="1">省</option>
                <option value="2">市</option>
                <option value="3">区</option>
            </select>
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">城市名称：</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="AreaName" name="AreaName" style="width:240px" placeholder="">
        </div>
    </div>

    <div class="layui-inline">
        <div class="layui-form-label">
            <button class="layui-btn" id="search" style="width: 60px; height: 28px; line-height: 28px; display: inline" data-type="reload">搜索</button>
        </div>
    </div>
    @*<div class="layui-inline">
            <div class="layui-form-block">
                <a asp-action="Add" class="layui-btn layui-btn-primary backIframe" style="width: 105px; height: 28px; line-height: 28px;">新增</a>
            </div>
        </div>*@
</blockquote>
<table class="layui-table" id="treeTable" lay-filter="datalist"></table>


